Skip to content

fix: update utcnow for python 3.12 deprecation #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

donbowman
Copy link
Contributor

In python3.12 we get deprecation errors due to the use of 'naive' timestamps
from utcnow. (see python/cpython#103857)

Replace with timezone.utc

See python/cpython#81669

See https://blog.miguelgrinberg.com/post/it-s-time-for-a-change-datetime-utcnow-is-now-deprecated

@dwt
Copy link

dwt commented Apr 28, 2025

I don't quite get why the .replace(tzinfo=None) is there? It would seem that timezone aware date times should be just as well to compute the total seconds. Other than that, this looks like it should solve the issue.

@dwt
Copy link

dwt commented Apr 28, 2025

@bobbui Is there anything I can do to make this more mergeable? Sadly the last run here is so long ago that the logs are not accessible anymore, so I'm not sure what the problem is.

But this is slowly becoming pressing as we want to update to python 3.14 soon.

@donbowman
Copy link
Contributor Author

i can remove the replace(tzinfo=None).
The only failure is for py3.7, which IMHO you would remove as it was EOL in 2023.

@donbowman
Copy link
Contributor Author

i have made a few minor changes to the test environment in this PR:

  • remove python3.7
  • pin sanic
  • update flake8 issues (flake8 is not pinned, neither is pytest)

now all the tests pass at this instance in time.

Copy link

@dwt dwt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small niggles, but definitely nice work!

@donbowman donbowman requested a review from dwt April 28, 2025 18:57
Copy link

@dwt dwt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Now how do we get @bobbui activated again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants